// import echarts from 'vue-echarts/components/ECharts';
export default function(params, _this) {
  console.log('pie data', Object.values(params))
  const pieData = Object.values(params)
  // 动态附加颜色
  if (pieData[0]) {
    const len = pieData.length
    pieData.forEach((item, index) => {
      item.name = _this.userSourceEnum[item.referer - 1] + ' ' + item.ratio
      item.value = item.num
      item.itemStyle = {
        color: `rgba(0, 79, 255, ${(index + 1) / len})` // 颜色平均分布
      }
    })
  }
  return {
    grid: {
      left: 10,
      right: 40,
      top: 0,
      bottom: 10,
      containLabel: true
    },
    tooltip: {
      trigger: 'item',
      formatter: '{a} <br/>{b}'
    },
    legend: {
      orient: 'vertical',
      left: '35%',
      top: 20,
      icon: 'circle',
      itemGap: 20,
      align: 'left'
    },
    series: [
      {
        name: '用户来源',
        type: 'pie',
        left: 'left',
        center: ['20%', '50%'],
        radius: ['70%', '90%'],
        avoidLabelOverlap: false,
        label: {
          show: false,
          position: 'center',
          formatter: '{d}'
        },
        emphasis: {
          label: {
            show: true,
            fontSize: '30',
            fontWeight: 'bold'
          }
        },
        labelLine: {
          show: false
        },
        data: pieData // 接口数据
      }
    ]
  }
}
